﻿using System;
using System.Collections.Generic;
using System.Text;
using Common;

namespace LoginServer
{
    public partial class User
    {
        public void SendMessage_L_Login_OK(int UserID)
        {
            SendMessage(MSG_GSM.L_Login_OK, BitConverter.GetBytes(UserID));
        }
        public void SendMessage_L_Login_Failed(string error)
        {
            byte[] data = Encoding.UTF8.GetBytes(error);
            List<byte> tmp = new List<byte>() {(byte)data.Length };
            tmp.AddRange(data);
            SendMessage(MSG_GSM.L_Login_Failed,tmp.ToArray());
        }
        public void SendMessage_L_CreatTable_OK(string tableinfo,byte[] IPAndPort)
        {
            List<byte> dataSend = new List<byte>();
            
            dataSend.AddRange(Encoding.UTF8.GetBytes(tableinfo));
            dataSend.AddRange(IPAndPort);
            SendMessage(MSG_GSM.L_CreateTable_OK, dataSend.ToArray());
        }
        public void SendMessage_L_JoinTable_Failed(string error)
        {
            byte[] data = Encoding.UTF8.GetBytes(error);
            List<byte> tmp = new List<byte>() { (byte)data.Length };
            tmp.AddRange(data);
            SendMessage(MSG_GSM.L_JoinTable_Error,tmp.ToArray());
        }
        public void SendMessage_L_JoinRoom_Failed(string error)
        {
            byte[] data = Encoding.UTF8.GetBytes(error);
            List<byte> tmp = new List<byte>() { (byte)data.Length };
            tmp.AddRange(data);
            SendMessage(MSG_GSM.L_JoinRoom_Error, tmp.ToArray());
        }
        public void SendMessage_L_OutTable_Failed()
        {
            SendMessage(MSG_GSM.L_OutTable_Error);
        }
        public void SendMessage_L_JoinTable_OK(string tableinfo,byte[] IPAndPort)
        {
            List<byte> dataSend = new List<byte>();
            dataSend.AddRange(Encoding.UTF8.GetBytes(tableinfo));
            dataSend.AddRange(IPAndPort);
            SendMessage(MSG_GSM.L_JoinTable_OK, dataSend.ToArray());
        }


        internal void SendMessage_L_CreateRoom_OK(string roominfo)
        {
            List<byte> dataSend = new List<byte>();
            dataSend.AddRange(Encoding.UTF8.GetBytes(roominfo));
            SendMessage(MSG_GSM.L_CreateRoom_OK, dataSend.ToArray());
        }

        internal void SendMessage_L_JoinRoom_OK(string roominfo)
        {
            List<byte> dataSend = new List<byte>();
            dataSend.AddRange(Encoding.UTF8.GetBytes(roominfo));
            SendMessage(MSG_GSM.L_JoinRoom_OK, dataSend.ToArray());
        }

        internal void SendMessage_L_OutRoom_Failed(string roominfo)
        {
            
            
        }

        internal void SendMessage_L_UpdateJoinRoom_OK(string playerinfo)
        {
            List<byte> dataSend = new List<byte>();
            dataSend.AddRange(Encoding.UTF8.GetBytes(playerinfo));
            SendMessage(MSG_GSM.L_Update_JoinRoom_OK, dataSend.ToArray());
        }

        public void SendMessage_L_Chat_Channel(string s)
        {
            byte[] data = Encoding.UTF8.GetBytes(s);
            List<byte> tmp = new List<byte>() { (byte)data.Length };
            tmp.AddRange(data);
            SendMessage(MSG_GSM.L_Chat_Channel, tmp.ToArray());
        }
        public void SendMessage_L_Chat_OK(string s)
        {
            byte[] data = Encoding.UTF8.GetBytes(s);
            List<byte> tmp = new List<byte>() { (byte)data.Length };
            tmp.AddRange(data);
            SendMessage(MSG_GSM.L_Chat_OK, tmp.ToArray());
        }

        public void SendMessage_L_Chat_Error(string s)
        {
            byte[] data = Encoding.UTF8.GetBytes(s);
            List<byte> tmp = new List<byte>() { (byte)data.Length };
            tmp.AddRange(data);
            SendMessage(MSG_GSM.L_Chat_Error, tmp.ToArray());
        }

        internal void SendMessage_L_OutRoom_OK(string roominfo)
        {
            List<byte> dataSend = new List<byte>();
            dataSend.AddRange(Encoding.UTF8.GetBytes(roominfo));
            SendMessage(MSG_GSM.L_OutRoom_OK, dataSend.ToArray());
        }

        internal void SendMessage_L_OutTable_OK(string tableinfo)
        {
            List<byte> dataSend = new List<byte>();
            dataSend.AddRange(Encoding.UTF8.GetBytes(tableinfo));
            SendMessage(MSG_GSM.L_OutTable_OK, dataSend.ToArray());
        }

        internal void SendMessage_L_UpdateOutRoom_OK(string playerinfo)
        {
            List<byte> dataSend = new List<byte>();
            dataSend.AddRange(Encoding.UTF8.GetBytes(playerinfo));
            SendMessage(MSG_GSM.L_Update_OutRoom_OK, dataSend.ToArray());
        }

        internal void SendMessage_L_RecurrenceTable_OK(string tableinfo)
        {
            List<byte> dataSend = new List<byte>();
            dataSend.AddRange(Encoding.UTF8.GetBytes(tableinfo));
            SendMessage(MSG_GSM.L_Recurrence_Table_OK, dataSend.ToArray());
        }


        internal void SendMessage_L_Update_Friend_OK(int UserID)
        {
            SendMessage(MSG_GSM.L_Update_Friend_OK, BitConverter.GetBytes(UserID));
        }

        internal void SendMessage_L_Update_Friend_Off_OK(int UserID)
        {
            SendMessage(MSG_GSM.L_Update_Friend_Off_OK, BitConverter.GetBytes(UserID));
        }
    }
}
